package castledefense.data;

import castledefense.util.Configure;
import castledefense.util.MeshGenerator;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Mesh;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.ParticleEffect;
import com.badlogic.gdx.graphics.g2d.Sprite;

/**
 * This class should hold all ressources that need loading. Exemple font, image,
 * etc.
 * 
 * @author Roi Atalla
 * 
 */
public final class Resources {
	public static final String filesPath = "res/";

	public static BitmapFont arialBold16;
	public static BitmapFont arialBold24;
	public static BitmapFont arialBold32;
	public static BitmapFont arialBold48;

	public static ParticleEffect fireUnitDeath;
	public static ParticleEffect waterUnitDeath;
	public static ParticleEffect airUnitDeath;
	public static ParticleEffect earthUnitDeath;

	public static ParticleEffect fireDotEffect;
	public static ParticleEffect earthStunEffect;
	public static ParticleEffect waterSlowEffect;

	public static ParticleEffect fireEffect;
	public static ParticleEffect waterEffect;
	public static ParticleEffect pyromancerEffect;
	public static ParticleEffect floodEffect;
	public static ParticleEffect blessedWindEffect;

	public static Texture castleIm;
	public static Texture fireBaseIm;
	public static Texture selectedIm;
	public static Texture missileIm;
	public static Texture cursorUnbuildableIm;
	public static Texture cursorBuildableIm;
	public static Texture cursorSellIm;
	public static Texture grassIm;
	public static Texture towerIm;
	public static Texture tower2Im;
	public static Texture gateIm;
	public static Texture gateFireIm;
	public static Texture gateEarthIm;
	public static Texture gateAirIm;
	public static Texture gateWaterIm;

	public static Texture fireUnitIm;
	public static Texture waterUnitIm;
	public static Texture airUnitIm;
	public static Texture earthUnitIm;
	public static Texture buildingPlatform;
	public static Mesh gridMesh;
	public static Texture pixel;

	public static void init() {

		arialBold16 = new BitmapFont(Gdx.files.internal(filesPath
				+ "font/ArialBold16.fnt"), Gdx.files.internal(filesPath
				+ "font/ArialBold16.png"), false);
		arialBold24 = new BitmapFont(Gdx.files.internal(filesPath
				+ "font/ArialBold24.fnt"), Gdx.files.internal(filesPath
				+ "font/ArialBold24.png"), false);
		arialBold32 = new BitmapFont(Gdx.files.internal(filesPath
				+ "font/ArialBold32.fnt"), Gdx.files.internal(filesPath
				+ "font/ArialBold32.png"), false);
		arialBold48 = new BitmapFont(Gdx.files.internal(filesPath
				+ "font/ArialBold48.fnt"), Gdx.files.internal(filesPath
				+ "font/ArialBold48.png"), false);

		waterSlowEffect = new ParticleEffect();

		waterSlowEffect.load(Gdx.files.internal(filesPath + "waterslow.txt"),
				Gdx.files.internal(filesPath));
		Configure.setFilter(waterSlowEffect);

		fireDotEffect = new ParticleEffect();
		fireDotEffect.load(Gdx.files.internal(filesPath + "firedot.txt"),
				Gdx.files.internal(filesPath));
		Configure.setFilter(fireDotEffect);

		earthStunEffect = new ParticleEffect();
		earthStunEffect.load(Gdx.files.internal(filesPath + "stun.txt"),
				Gdx.files.internal(filesPath));
		Configure.setFilter(earthStunEffect);

		fireEffect = new ParticleEffect();
		fireEffect.load(Gdx.files.internal(filesPath + "fire.txt"),
				Gdx.files.internal(filesPath));
		Configure.setFilter(fireEffect);

		waterEffect = new ParticleEffect();
		waterEffect.load(Gdx.files.internal(filesPath + "water.txt"),
				Gdx.files.internal(filesPath));
		Configure.setFilter(waterEffect);

		pyromancerEffect = new ParticleEffect();
		pyromancerEffect.load(Gdx.files.internal(filesPath + "pyromancer.txt"),
				Gdx.files.internal(filesPath));
		Configure.setFilter(pyromancerEffect);

		floodEffect = new ParticleEffect();
		floodEffect.load(Gdx.files.internal(filesPath + "flood.txt"),
				Gdx.files.internal(filesPath));
		Configure.setFilter(floodEffect);
		blessedWindEffect = new ParticleEffect();
		blessedWindEffect.load(
				Gdx.files.internal(filesPath + "blessedwind.txt"),
				Gdx.files.internal(filesPath));
		Configure.setFilter(blessedWindEffect);

		castleIm = new Texture(Gdx.files.internal(filesPath + "castle.png"));
		Configure.setFilter(castleIm);

		fireBaseIm = new Texture(Gdx.files.internal(filesPath + "firebase.png"));
		Configure.setFilter(fireBaseIm);

		missileIm = new Texture(Gdx.files.internal(filesPath + "missile.png"));
		Configure.setFilter(missileIm);

		cursorUnbuildableIm = new Texture(Gdx.files.internal(filesPath
				+ "cursorunbuildable.png"));
		Configure.setFilter(cursorUnbuildableIm);

		cursorBuildableIm = new Texture(Gdx.files.internal(filesPath
				+ "cursorbuildable.png"));
		Configure.setFilter(cursorBuildableIm);

		cursorSellIm = new Texture(Gdx.files.internal(filesPath
				+ "cursorsell.png"));
		Configure.setFilter(cursorSellIm);

		grassIm = new Texture(Gdx.files.internal(filesPath + "grass.png"));
		Configure.setFilter(grassIm);

		towerIm = new Texture(Gdx.files.internal(filesPath + "obelisk.png"));
		Configure.setFilter(towerIm);

		tower2Im = new Texture(Gdx.files.internal(filesPath + "obelisk2.png"));
		Configure.setFilter(tower2Im);

		gateIm = new Texture(Gdx.files.internal(filesPath + "gate.png"));
		Configure.setFilter(gateIm);

		gateFireIm = new Texture(Gdx.files.internal(filesPath + "gatefire.png"));
		Configure.setFilter(gateFireIm);

		gateWaterIm = new Texture(Gdx.files.internal(filesPath
				+ "gatewater.png"));
		Configure.setFilter(gateWaterIm);

		gateAirIm = new Texture(Gdx.files.internal(filesPath + "gateair.png"));
		Configure.setFilter(gateAirIm);

		gateEarthIm = new Texture(Gdx.files.internal(filesPath
				+ "gateearth.png"));
		Configure.setFilter(gateEarthIm);

		selectedIm = new Texture(
				Gdx.files.internal(filesPath + "selection.png"));
		Configure.setFilter(selectedIm);

		fireUnitIm = new Texture(Gdx.files.internal(filesPath + "fireunit.png"));
		Configure.setFilter(fireUnitIm);

		earthUnitIm = new Texture(Gdx.files.internal(filesPath
				+ "earthunit.png"));
		Configure.setFilter(earthUnitIm);

		airUnitIm = new Texture(Gdx.files.internal(filesPath + "airunit.png"));
		Configure.setFilter(airUnitIm);

		waterUnitIm = new Texture(Gdx.files.internal(filesPath
				+ "waterunit.png"));
		Configure.setFilter(waterUnitIm);

		buildingPlatform = new Texture(Gdx.files.internal(filesPath
				+ "buildingplatform.png"));
		Configure.setFilter(waterUnitIm);

		pixel = new Texture(Gdx.files.internal(filesPath + "pixel.png"));

		fireUnitDeath = new ParticleEffect();
		fireUnitDeath.load(Gdx.files.internal(filesPath + "unitdeath.txt"),
				Gdx.files.internal(filesPath));
		waterUnitDeath = new ParticleEffect(fireUnitDeath);
		airUnitDeath = new ParticleEffect(fireUnitDeath);
		earthUnitDeath = new ParticleEffect(fireUnitDeath);
		fireUnitDeath.getEmitters().get(0).setSprite(new Sprite(fireUnitIm));
		waterUnitDeath.getEmitters().get(0).setSprite(new Sprite(waterUnitIm));
		airUnitDeath.getEmitters().get(0).setSprite(new Sprite(airUnitIm));
		earthUnitDeath.getEmitters().get(0).setSprite(new Sprite(earthUnitIm));

		gridMesh = MeshGenerator.MapGrid();

	}

	public static void dispose() {
		arialBold16.dispose();
		arialBold24.dispose();
		arialBold32.dispose();
		arialBold48.dispose();
		fireDotEffect.dispose();
		earthStunEffect.dispose();
		waterSlowEffect.dispose();
		fireEffect.dispose();
		waterEffect.dispose();
		pyromancerEffect.dispose();
		floodEffect.dispose();
		blessedWindEffect.dispose();
		cursorSellIm.dispose();
		cursorBuildableIm.dispose();
		cursorUnbuildableIm.dispose();
		grassIm.dispose();
		towerIm.dispose();
		tower2Im.dispose();
		gateIm.dispose();
		gateFireIm.dispose();
		gateWaterIm.dispose();
		gateEarthIm.dispose();
		gateAirIm.dispose();
		selectedIm.dispose();
		castleIm.dispose();
		missileIm.dispose();
		fireUnitIm.dispose();
		airUnitIm.dispose();
		earthUnitIm.dispose();
		waterUnitIm.dispose();
		pixel.dispose();
		buildingPlatform.dispose();

	}
}
